import React, { Component } from 'react';
import { PageHeader, Divider } from 'antd';
import { query, dateFmt } from '../utils/utils';
// 导入样式文件
import '../assets/css/detail.css';
import { Redirect } from 'react-router-dom';

class Detail extends Component {
    constructor(props) {
        super(props);
        this.state = {
            info: {}
        }
    }
    getDetail() {
        query(`/topic/${this.props.match.params.id}`).then(res => {
            this.setState({
                info: res.data
            });
        });
    }
    componentWillMount() {
        this.getDetail();
    }
    render() {
        return (
            <div>
                <PageHeader
                    className="site-page-header"
                    onBack={() => this.back()}
                    title={this.state.info.title}
                    subTitle={dateFmt(this.state.info.create_at)}
                />
                {/* <h1>文章详情-{this.props.match.params.id}</h1> */}
                {/* <Paragraph>{this.state.info.content}</Paragraph> */}
                <Divider />
                <div className="content" dangerouslySetInnerHTML={{ __html: this.state.info.content }}></div>
            </div>
        );
    }
    back() {
        this.props.history.go(-1);
        // this.props.history.push('/lists');
    }
}

export default Detail;
